public class student {
        private int id;
        private String name;
        private String telephone;
        private int age;
        private char gender;
        public void study(){
        System.out.println("学生在学习!");
        }
        public void set_name(String name){
                if(name.length() ==3||name.length() ==2){
                        //this关键字可调用全局变量
                        //当既有全局又有局部变量时，变量调用采用就近原则
                        this.name = name;
                }else{
                        System.out.println("输入名字非法");
                }
        }

        public String getName() {
                return name;
        }

        public void set_age(int t_age){
                if(t_age>=18&&t_age<=30){
                        age = t_age;
                }else{
                        System.out.println("输入年龄非法");
                }
        }

        public int getAge() {
                return age;
        }
        //构造方法
        //如果没有写构造方法，系统会默认创建一个空参的构造方法
        //创造对象的时候虚拟机会自动调用构造方法，作用是给成员变量进行初始化的
        public student (){
                System.out.println("天忙星nb!");
        }
        public student (int id,String name,String telephone){
        this.name = name;
        this.id = id;
        this.telephone = telephone;
        }
}
